<template>
  <div class="file-wrap">
    <el-image
      fit="contain"
      style="width: 100px; height: 100px"
      :src="file"
      :preview-src-list="[file]"
      preview-teleported
      lazy
    >
      <template #error>
        <div class="image-error">
          <el-icon><icon-picture /></el-icon>
        </div>
      </template>
    </el-image>
  </div>
</template>

<script lang="ts" setup>
import { type PropType, computed } from 'vue'
import { Picture as IconPicture } from '@element-plus/icons-vue'

import type { OssApiResult } from '@/api/oss'

const props = defineProps({
  file: {
    type: String,
    default: ''
  }
})
</script>

<style lang="scss" scoped>
.file-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100px;
  font-size: 50px;

  .image-error {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    background: var(--el-fill-color-light);
    color: var(--el-text-color-secondary);
  }
}
</style>
